<!--
 * @Description: 
 * @version: 
 * @Author: 尹鹏孝
 * @Date: 2022-02-14 16:21:49
 * @LastEditors: 尹鹏孝
 * @LastEditTime: 2022-02-14 16:46:15
-->
<html>

<head></head>

<body>

    <script>
        let replaceState = function (s) {
            const strAss = Array.from(s);
            let count = 0;
            for (let i = 0; i < strAss.length; i++) {
                if (strAss[i] === ' ') {
                    count++;
                }
            }
            let left = strAss.length - 1;
            let right = strAss.length + count * 2 - 1;
            while (left >= 0) {
                if (strAss[left] === ' ') {
                    strAss[left--] = "0";
                    strAss[right--] = "2";
                    strAss[right--] = "%";
                    left--;
                } else {
                    strAss[right--] = strAss[left--];
                }
            }
            return strAss.join("");

        }
    </script>
</body>

</html>